package com.example.demoview;

import controller.MyController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import org.springframework.boot.SpringApplication;
import org.springframework.web.servlet.ModelAndView;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;



@RestController
@SpringBootApplication
public class DemoviewApplication {

	@RequestMapping("/")
	public String index(){
		//return "Hello World， Spring boot is good  index";
		return "index";
	}

	@RequestMapping("/login")
	public ModelAndView testlogin(){
		Login login =new Login();
		return login.logintest();
	}

	@PostMapping("/dologin")
	public Map dologin(@RequestParam Map<String,Object> params){

		String login_id=(String) params.get("login_id");
		String passwd=(String) params.get("passwd");
		Map user_Map = new HashMap();
		user_Map.put("login_id",login_id);
		user_Map.put("passwd",passwd);
		return user_Map;
	}

	@GetMapping("/dptest1")
	public Map dptest1(){
		Map user_Map = new HashMap();
		user_Map.put("login_id","登录id");
		user_Map.put("passwd","登录mm");
		return user_Map;
	}

	@GetMapping("/testdp")
	public ResponseEntity<String> usingResponseEntityBuilderAndHttpHeaders() {

		MyHeaders myHeaders =new MyHeaders();
		HttpHeaders responseHeaders = myHeaders.myHeaders();
		return ResponseEntity.ok()
				.headers(responseHeaders)
				.body("Response with header using ResponseEntity");
	}

	@GetMapping("/testdp1")
	public ResponseEntity<Map> usingResponseMap() {

		MyHeaders myHeaders =new MyHeaders();
		HttpHeaders responseHeaders = myHeaders.myHeaders();

		Map user_Map = new HashMap();
		user_Map.put("login_id","登录id");
		user_Map.put("passwd","登录mm");
		return ResponseEntity.ok()
				.headers(responseHeaders)
				.body(user_Map);
	}

	////////////////////////////////////////////////////////////
	@GetMapping("/data/gk")
	public ResponseEntity<Map> DataGk() {

		MyHeaders myHeaders =new MyHeaders();
		HttpHeaders responseHeaders = myHeaders.myHeaders();

		GkData datagk = new GkData();
		Map rejson = datagk.DataGk();

		return ResponseEntity.ok()
				.headers(responseHeaders)
				.body(rejson);
	}

	@GetMapping("/data/sshy")
	public ResponseEntity<Map> DataSshy() {

		MyHeaders myHeaders =new MyHeaders();
		HttpHeaders responseHeaders = myHeaders.myHeaders();

		SshyData datasshy = new SshyData();
		Map rejson = datasshy.DataSshy();

		return ResponseEntity.ok()
				.headers(responseHeaders)
				.body(rejson);
	}

	@GetMapping("/data/sslc")
	public ResponseEntity<Map> DataSslc() {

		MyHeaders myHeaders =new MyHeaders();
		HttpHeaders responseHeaders = myHeaders.myHeaders();

		SslcData datasslc = new SslcData();
		Map rejson = datasslc.DataSslc();

		return ResponseEntity.ok()
				.headers(responseHeaders)
				.body(rejson);
	}

	@GetMapping("/data/hy")
	public ResponseEntity<Map> DataHy() {

		MyHeaders myHeaders =new MyHeaders();
		HttpHeaders responseHeaders = myHeaders.myHeaders();

		HyData datahy = new HyData();
		Map rejson = datahy.DataHy();

		return ResponseEntity.ok()
				.headers(responseHeaders)
				.body(rejson);
	}

	@GetMapping("/data/fenlei")
	public ResponseEntity<Map> DataFenLei() {

		MyHeaders myHeaders =new MyHeaders();
		HttpHeaders responseHeaders = myHeaders.myHeaders();

		FenLeiData datafenlei = new FenLeiData();
		Map rejson = datafenlei.DataFenLei();

		return ResponseEntity.ok()
				.headers(responseHeaders)
				.body(rejson);
	}

	@GetMapping("/data/huizong")
	public ResponseEntity<Map> DataHuiZong() {

		MyHeaders myHeaders =new MyHeaders();
		HttpHeaders responseHeaders = myHeaders.myHeaders();

		HuiZongData datahuizong = new HuiZongData();
		Map rejson = datahuizong.DataHuiZong();

		return ResponseEntity.ok()
				.headers(responseHeaders)
				.body(rejson);
	}




	public static void main(String[] args) {
		SpringApplication.run(DemoviewApplication.class, args);
		//SpringApplication.run(MyController.class, args);
		//SpringApplication application = new SpringApplication(MyController.class,DemoviewApplication.class,mytest.class,myhello.class);
		//application.run(args);
	}

}
